import request from '../utils/request'

export function putPrescription (data) {
  return request({
    method: 'put',
    url: 'app/prescription',
    data: data
  })
}

export function putPrescriptionItem (data) {
  return request({
    method: 'put',
    url: 'app/prescription/item',
    data: data
  })
}

export function getPrescription (name, labelId, pageSize, currentPage) {
  return request({
    method: 'get',
    url: 'app/prescription',
    params: {
      name: name,
      'label-id': labelId,
      'page-size': pageSize,
      'current-page': currentPage
    }
  })
}

export function getPrescriptionItem (prescriptionId) {
  return request({
    method: 'get',
    url: 'app/prescription/item',
    params: {
      'prescription-id': prescriptionId,
    }
  })
}

export function postPrescriptionItem (data) {
  return request({
    method: 'post',
    url: 'app/prescription/item',
    data: data
  })
}

export function postPrescription (data) {
  return request({
    method: 'post',
    url: 'app/prescription',
    data: data
  })
}

export function deletePrescriptionItem (id, prescriptionId) {
  return request({
    method: 'delete',
    url: 'app/prescription/item',
    params: {
      id: id,
      'prescription-id': prescriptionId
    }
  })
}

export function deletePrescription (data) {
  return request({
    method: 'delete',
    url: 'app/prescription',
    data: {
      id: data
    }
  })
}
